mui.init({
	swipeBack: false
});
App.init();
var contentVm = new Vue({
	el: '#content',
	data: {
		immersed: 0,
		mobile: '',
		captcha: '',
		sendCodeText: '验证',
		sendCodeTime: '60'
	},
	watch: {},
	mounted: function() {
		var that = this;
		if(window.plus) {
			that.plusReady();
		} else {
			document.addEventListener('plusready', that.plusReady, false);
		}

	},
	methods: {
		plusReady: function() {
			var that = this;
			var currentWebview = plus.webview.currentWebview();
			that.immersed = App.getImmersed()
		},

	}
})
mui('body').on('tap', '#closeLoginMobileWrapper', function() {
	$('#loginMobileWrapper').fadeOut(100)
})

mui('body').on('tap', '#closeLogin', function() {
	mui.back();
})

mui('body').on('tap', '.login-btn-item', function() {
	var type = $(this).data('type');
	switch(type) {
		case 'wechat':
			break;
		case 'alipay':
			break;
		default:
			$('#loginMobileWrapper').show();
			break;
	}
})
mui('body').on('tap', '#sendCode', function() {
	Http.post('sendSms', {
		data: {
			event: 'mobilelogin',
			mobile: contentVm.mobile
		},
		success: function(res) {
			contentVm.sendCodeTime -= 1;
			contentVm.sendCodeText = contentVm.sendCodeTime + '秒';
			var timer = setInterval(function() {
				if(contentVm.sendCodeTime == 0) {
					clearInterval(timer);
					contentVm.sendCodeTime = 60;
					contentVm.sendCodeText = '验证';
				} else {
					contentVm.sendCodeTime -= 1;
					contentVm.sendCodeText = contentVm.sendCodeTime + '秒';
				}
			}, 1000)
		}
	})

})
mui('body').on('tap', '#login', function() {
	Http.post('loginWithMobile', {
		data: {
			captcha: contentVm.captcha,
			mobile: contentVm.mobile
		},
		success: function(res) {
			var userInfo = res.data.userinfo;
			userInfo.avatar = 'http://powerbank.imcyk.com' + userInfo.avatar;
			localStorage.userInfo = JSON.stringify(userInfo);
			App.commandToGetNewUserInfo();
			mui.back();
		}
	})
})